#include "process_bar.h"
void download(callback_t cb)
{
    int testcnt = 100;
    int target = TARGET_SIZE;
    int total = 0;

    while (total <= target)
    {
        usleep(STIME); // 用简单的休眠时间，模拟本轮下载花费的时间
        total += DSIZE;
        double rate = total * 100.0/ target;


        //模拟卡顿
        // if(rate>50.0&&testcnt)
        //{
          // total=target/2;
          // testcnt--;
        //}


        cb(rate);//回调函数
    }
    cb(MAX_RATE);//回调函数
    printf("\n");
}
int main()
{
    download(process_bar);
    return 0;
}
